﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using Model;

namespace UI
{
    public partial class 餐桌添加 : Form
    {
        public 餐桌添加()
        {
            InitializeComponent();
        }
        主界面 f;
        public 餐桌添加(主界面 f)
        {
            InitializeComponent();
            this.f = f;
        }
        private void 餐桌添加_Load(object sender, EventArgs e)
        {
            DataSet ds = 餐桌信息BLL.selectRoot();
            this.comboBox1.DataSource = ds.Tables[0];
            this.comboBox1.ValueMember = "RTID";
            this.comboBox1.DisplayMember = "RTName";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string name = this.textBox1.Text;
            string Area = this.textBox2.Text;
            餐桌Model.TableState = this.comboBox1.SelectedValue.ToString();
            if (name == "" || Area == "")
            {
                MessageBox.Show("所有的数据都不能为空!", "温馨提示");
                return;
            }
            餐桌Model.TableName = name;
            餐桌Model.TableArea = Area;
            object Table = 餐桌信息BLL.SelectTableName();
            if (Convert.ToInt32(Table)>0)
            {
                MessageBox.Show("已经有相同的餐桌名");
            }
            else
            {
                int count = 餐桌信息BLL.Add();
                if (count > 0)
                {
                    MessageBox.Show("添加成功");
                    f.Zz();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("日期格式错误");
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
